<?php
namespace app\post\controller\admin;
use app\common\controller\Admin;
use app\common\traits\ControllerCurd;
use think\Request;
use app\common\annotation\NodeAnnotation;
/**
 * @NodeAnnotation(
 *     title="收藏模块",
 *     parent="post/admin.index",
 *     is_menu=0,
 *     is_view=0,
 *     auth=1,
 * )
 */
class Collection extends Admin
{
    use ControllerCurd;
    public $model = '';
    public function initialize()
    {
        parent::initialize();
        $this->model = new \app\post\model\CollectionModel();
    }

    /**
     * @NodeAnnotation(
     *     title="收藏管理",
     *     parent="post/admin.collection",
     *     MenuRoot="post/admin.index"
     * )
     */
    public function index(Request $request)
    {
        $keywords  = $request->param("keywords");

        $where = [];

        if($keywords) array_push($where,['name',"like","%$keywords%"]);

        $tagList = $this->model->where($where)
            ->withAttr("user_id")
            ->paginate();

        $this->assign([
            "tagList" => $tagList,
            "search"  => [
                "keywords" => $keywords
            ]
        ]);
        return view();
    }

}